WordPress

推荐列表 站点导航

当前位置:首页 > 建站教程 > WordPress >

获取侧边栏WordPress函数get_sidebar用法

来源:网络整理  作者:网络  发布时间:2020-12-13 19:24
获取侧边栏WordPress函数get_sidebar用法:get_sidebar函数位于wp-includes/general-template.php第100行左右,函数原型如下:fu...

* @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.

<?php get_sidebar('daimadog');?>

/**

locate_template( $templates, true );

* you would specify the filename in the hook as get_sidebar( 'new' ).

使用方法

获取侧边栏WordPress函数get_sidebar用法:

$templates = array();

*

获取侧边栏WordPress函数get_sidebar用法 (https://www.ym97.com/wenku/) WordPress使用教程 第1张

function get_sidebar( $name = null ) {

* Fires before the sidebar template file is loaded.

<?php get_sidebar();?>

* @since 2.8.0 $name parameter added.

*

$name = (string) $name;

如果使用传入参数daimadog,将会加载主题目录下sidebar-daimadog.php文件作为侧边栏。

}

* default sidebar template file. If your file is called sidebar-new.php,

do_action( 'get_sidebar', $name );

$templates[] = 'sidebar.php';

函数介绍

*

$templates[] = "sidebar-{$name}.php";

* The hook allows a specific sidebar template file to be used in place of the

get_sidebar函数位于wp-includes/general-template.php第100行左右,函数原型如下:

* @since 2.2.0

由上述代码可以看出,get_sidebar函数需要一个字符串类型参数,该参数可以为空,为空时会自动查找主题目录下的sidebar.php文件作为侧边栏,如果主题目录下没有sidebar.php文件将会使用默认的 wp-includes/theme-compat/sidebar.php 文件作为侧边栏。如果传入参数,则会引入sidebar-参数名.php作为侧边栏。

*/

if ( '' !== $name )

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jz/wp/3427.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

获取侧边栏WordPress函数get_sidebar用法

2020-12-13 编辑:网络

* @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.

<?php get_sidebar('daimadog');?>

/**

locate_template( $templates, true );

* you would specify the filename in the hook as get_sidebar( 'new' ).

使用方法

获取侧边栏WordPress函数get_sidebar用法:

$templates = array();

*

获取侧边栏WordPress函数get_sidebar用法 (https://www.ym97.com/wenku/) WordPress使用教程 第1张

function get_sidebar( $name = null ) {

* Fires before the sidebar template file is loaded.

<?php get_sidebar();?>

* @since 2.8.0 $name parameter added.

*

$name = (string) $name;

如果使用传入参数daimadog,将会加载主题目录下sidebar-daimadog.php文件作为侧边栏。

}

* default sidebar template file. If your file is called sidebar-new.php,

do_action( 'get_sidebar', $name );

$templates[] = 'sidebar.php';

函数介绍

*

$templates[] = "sidebar-{$name}.php";

* The hook allows a specific sidebar template file to be used in place of the

get_sidebar函数位于wp-includes/general-template.php第100行左右,函数原型如下:

* @since 2.2.0

由上述代码可以看出,get_sidebar函数需要一个字符串类型参数,该参数可以为空,为空时会自动查找主题目录下的sidebar.php文件作为侧边栏,如果主题目录下没有sidebar.php文件将会使用默认的 wp-includes/theme-compat/sidebar.php 文件作为侧边栏。如果传入参数,则会引入sidebar-参数名.php作为侧边栏。

*/

if ( '' !== $name )

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jz/wp/3427.shtml

相关文章

风云图片

推荐阅读

返回WordPress频道首页